﻿<phone:PhoneApplicationPage 
    x:Class="MusicAlarm7.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:sl="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:viewmod="clr-namespace:MusicAlarm7.DataModel;assembly=DataModel"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot 是包含所有页面内容的根网格-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.Resources>
            <viewmod:RecurringDaysConverter x:Key="RecurringDaysConverter"/>
            <viewmod:RecurrenceSummaryConverter x:Key="RecurrenceSummaryConverter" />
            <viewmod:EtaTimeSpanConverter x:Key="EtaTimeSpanConverter" />
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel 包含应用程序的名称和页标题-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="{Binding Path=LocalizedResources.AppTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="{Binding Path=LocalizedResources.MainPage_Title, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - 在此处放置其他内容-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ListBox Name="NotificationListBox" ItemsSource="{Binding Alarms}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Background="Transparent" Margin="0,0,0,30">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="340"/>
                                <ColumnDefinition Width="90"/>
                            </Grid.ColumnDefinitions>
                            <Grid Grid.Column="0" Tap="NotificationListBox_Tap">
                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="{Binding AlarmTime, StringFormat=t}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" FontWeight="Bold" />
                                    <TextBlock Text="{Binding Path=Eta, Converter={StaticResource EtaTimeSpanConverter}}" />
                                    <TextBlock Text="{Binding MusicName}" />
                                    <TextBlock Text="{Binding Path=RecurringDays, Converter={StaticResource RecurrenceSummaryConverter}}" />
                                </StackPanel>
                            </Grid>
                            <Grid Grid.Column="1">
                                <sl:ToggleSwitch IsChecked="{Binding Path=IsEnabled, Mode=TwoWay}" Click="ToggleSwitch_Click" />
                            </Grid>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>